package com.qingxin.park.entity;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.hibernate.annotations.GenericGenerator;

/**
 * 园区地块表
 */
@Entity
@Table(name = "park_block")
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
public class ParkBlock extends com.qingxin.sys.entity.BaseEntity implements
		java.io.Serializable {
	private static final long serialVersionUID = 6983905689755479362L;
	private String blockid;
	private FarmPark farmPark;
	private String blockCode;
	private String blockName;
	private String blockType;//用途：1种植、2养殖、3加工
	private String isuse;//0:闲置1:正常
	private String isdel;//0正常1删除
	private String remark;
	private Double area;
	private Double lat;
	private Double lng;
	private String createBy;
	private Date createTime;
	private String updateBy;
	private Date updateTime;
	private Set<ParkBlockPlant> parkBlockPlants = new HashSet<>(0);
	private Set<SysUserBlockRel> sysUserBlockRels = new HashSet<>(0);

	// Constructors

	/** default constructor */
	public ParkBlock() {
	}
	
	public ParkBlock(String blockid) {
		this.blockid = blockid;
	}


	public ParkBlock(String blockid, String blockName, String parkid) {
		this.blockid = blockid;
		this.blockName = blockName;
		this.farmPark = new FarmPark(parkid);
	}

	/** minimal constructor */
	public ParkBlock(FarmPark farmPark) {
		this.farmPark = farmPark;
	}
	
	
	public ParkBlock(String blockid, String blockCode, String blockName,
			String blockType, String isuse, Double area) {
		this.blockid = blockid;
		this.blockCode = blockCode;
		this.blockName = blockName;
		this.blockType = blockType;
		this.isuse = isuse;
		this.area = area;
	}

	/** full constructor */
	public ParkBlock(FarmPark farmPark, String blockCode, String blockName, String blockType,
			String isuse, String isdel, String remark, Double area, Double lat, Double lng,
			String createBy, Date createTime, String updateBy,
			Date updateTime, Set<ParkBlockPlant> parkBlockPlants,
			Set<SysUserBlockRel> sysUserBlockRels) {
		this.farmPark = farmPark;
		this.blockCode = blockCode;
		this.blockName = blockName;
		this.blockType = blockType;
		this.isuse = isuse;
		this.isdel = isdel;
		this.remark = remark;
		this.area = area;
		this.lat = lat;
		this.lng = lng;
		this.createBy = createBy;
		this.createTime = createTime;
		this.updateBy = updateBy;
		this.updateTime = updateTime;
		this.parkBlockPlants = parkBlockPlants;
		this.sysUserBlockRels = sysUserBlockRels;
	}

	// Property accessors
	@GenericGenerator(name = "generator", strategy = "uuid.hex")
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "blockid", unique = true, nullable = false, length = 32)
	public String getBlockid() {
		return this.blockid;
	}

	public void setBlockid(String blockid) {
		this.blockid = blockid;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "parkid", nullable = false)
	public FarmPark getFarmPark() {
		return this.farmPark;
	}

	public void setFarmPark(FarmPark farmPark) {
		this.farmPark = farmPark;
	}

	@Column(name = "block_code", length = 20)
	public String getBlockCode() {
		return this.blockCode;
	}

	public void setBlockCode(String blockCode) {
		this.blockCode = blockCode;
	}

	@Column(name = "block_name", length = 50)
	public String getBlockName() {
		return this.blockName;
	}

	public void setBlockName(String blockName) {
		this.blockName = blockName;
	}

	@Column(name = "block_type", length = 1)
	public String getBlockType() {
		return blockType;
	}

	public void setBlockType(String blockType) {
		this.blockType = blockType;
	}

	@Column(name = "isuse", length = 1)
	public String getIsuse() {
		return this.isuse;
	}

	public void setIsuse(String isuse) {
		this.isuse = isuse;
	}
	
	@Column(name = "isdel", length = 1)
	public String getIsdel() {
		return isdel;
	}
	public void setIsdel(String isdel) {
		this.isdel = isdel;
	}

	@Column(name = "remark", length = 1000)
	public String getRemark() {
		return this.remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Column(name = "area", precision = 16, scale = 4)
	public Double getArea() {
		return this.area;
	}

	public void setArea(Double area) {
		this.area = area;
	}

	@Column(name = "lat", precision = 16, scale = 10)
	public Double getLat() {
		return this.lat;
	}

	public void setLat(Double lat) {
		this.lat = lat;
	}

	@Column(name = "lng", precision = 16, scale = 10)
	public Double getLng() {
		return this.lng;
	}

	public void setLng(Double lng) {
		this.lng = lng;
	}

	@Column(name = "create_by", length = 32)
	public String getCreateBy() {
		return this.createBy;
	}

	public void setCreateBy(String createBy) {
		this.createBy = createBy;
	}

	@Column(name = "create_time", length = 23)
	public Date getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Column(name = "update_by", length = 32)
	public String getUpdateBy() {
		return this.updateBy;
	}

	public void setUpdateBy(String updateBy) {
		this.updateBy = updateBy;
	}

	@Column(name = "update_time", length = 23)
	public Date getUpdateTime() {
		return this.updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "parkBlock")
	@JsonIgnore
	public Set<ParkBlockPlant> getParkBlockPlants() {
		return this.parkBlockPlants;
	}

	public void setParkBlockPlants(Set<ParkBlockPlant> parkBlockPlants) {
		this.parkBlockPlants = parkBlockPlants;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "parkBlock")
	@JsonIgnore
	public Set<SysUserBlockRel> getSysUserBlockRels() {
		return this.sysUserBlockRels;
	}

	public void setSysUserBlockRels(Set<SysUserBlockRel> sysUserBlockRels) {
		this.sysUserBlockRels = sysUserBlockRels;
	}

}